<?php

namespace App\Models;

use Dcat\Admin\Traits\ModelTree;
use Illuminate\Database\Eloquent\SoftDeletes;
use Spatie\EloquentSortable\Sortable;
use Spatie\EloquentSortable\SortableTrait;

class BannerModel extends AbstractBaseModel
{
    use SoftDeletes;
    protected $table = 'banners';
    // 设置排序字段，默认order

    const TYPE_URL = 1;//外链
    const TYPE_POSITION_DETAILS = 2;//职位详情
    const TYPE_SPECIAL_SECTION = 3;//专区
    const TYPE_NONE = 4;//无跳转
    const TYPE_LIST = [
        self::TYPE_URL => '外链',
        self::TYPE_POSITION_DETAILS => '职位详情',
        self::TYPE_SPECIAL_SECTION => '专区',
        self::TYPE_NONE => '无跳转',

    ];

    const GENRE_INDEX = 1;//首页
    const GENRE_PLAZA = 2;//广场

    const GENRE_LIST = [
        self::GENRE_INDEX=>'首页',
        self::GENRE_PLAZA=>'广场',
    ];

     // 定义多对多关系
     public function platforms()
     {
         return $this->belongsToMany(PlatformModel::class, BannersPlatformModel::class, 'banner_id', 'platform_id')
             ->withTimestamps();
     }

}
